//! Pipit配置系统
//! 提供显式的特性使用控制

/// 核心优化特性开关
pub struct FeatureConfig {
    /// 是否启用零拷贝内存
    pub zero_copy_memory: bool,
    /// 是否启用内存压缩
    pub memory_compression: bool,
    /// 是否启用大对象优化
    pub large_object_optimization: bool,
    /// 是否启用并发GC
    pub concurrent_gc: bool,
    /// 是否启用高级优化
    pub advanced_optimizations: bool,
    /// 是否启用调试器
    pub debugger: bool,
}

impl FeatureConfig {
    /// 创建默认配置（所有特性显式启用）
    pub fn default_enabled() -> Self {
        Self {
            zero_copy_memory: true,
            memory_compression: true,
            large_object_optimization: true,
            concurrent_gc: true,
            advanced_optimizations: true,
            debugger: false, // 保持调试器默认禁用
        }
    }

    /// 创建最小配置（仅核心优化）
    pub fn minimal() -> Self {
        Self {
            zero_copy_memory: false,
            memory_compression: false,
            large_object_optimization: false,
            concurrent_gc: false,
            advanced_optimizations: false,
            debugger: false,
        }
    }

    /// 检查特性是否启用
    pub fn is_enabled(&self, feature: &str) -> bool {
        match feature {
            "zero_copy_memory" => self.zero_copy_memory,
            "memory_compression" => self.memory_compression,
            "large_object_optimization" => self.large_object_optimization,
            "concurrent_gc" => self.concurrent_gc,
            "advanced_optimizations" => self.advanced_optimizations,
            "debugger" => self.debugger,
            _ => false,
        }
    }
}

/// 全局特性配置实例
pub static FEATURE_CONFIG: once_cell::sync::Lazy<FeatureConfig> = 
    once_cell::sync::Lazy::new(FeatureConfig::default_enabled);